var webpack=require('webpack');
var HtmlWebpackPlugin=require('html-webpack-plugin');

module.exports={
	devtool: 'eval,-source-map',//配置生成source maps,选择合适的选项
	entry:__dirname+"/app/main.js",//入口文件
	output:{
		path:__dirname+"/build",//打包后文件存放的地方
		filename:"bundle.js"//打包输出的文件名称
	},

	module: {//在配置文件里添加 json loader
		loaders: [
			{
				test: /\.json$/,
				loader: "json"
			},
			{
				test: /\.js$/,
				exclude: /node_modules/,
				loader: 'babel',
				query: {
					"presets": ['es2015','react'],
					"env": {
					"development":{
						"plugins": [["react-transform",{
							"transforms":[{
								"transform": "react-transform-hmr",
								"imports": ["react"],
								"locals":["module"]
							}]
						}]]
					}
				}
				},

			},
			{
				test: /\.css$/,
				loader: 'style!css?modules'
			}
		]
	},
	postcss: [
		require('autoprefixer')
	],
	plugins: [
		new HtmlWebpackPlugin({
			template:__dirname+"/app/index.tmpl.html"
		}),
		new webpack.HotModuleReplacementPlugin()//热加载插件
	],
	devServer: {
		//contentBase: "./public",//本地服务器加载页面所在的目录
		colors: true,//终端输出的结果为彩色
		port: 8089,
		historyApiFallback: true,//不跳转
		inline: true, //实时刷新
		hot: true
	}
}
//__dirname(两个下划线)是nodejs中的全局变量，指向当前执行脚本所在的目录